package com.baidu.process.chat.core.web.controller;

import com.baidu.process.chat.core.web.bean.eval.EvalResult;
import com.baidu.process.chat.core.web.bean.eval.R;
import com.baidu.process.chat.core.web.service.IEvalService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: lws
 * @date: 2022/12/15
 */
@RestController
@RequestMapping("/eval")
public class EvalController {
    @Resource
    private IEvalService evalService;

    /**
     * 获取session对应数据
     *
     * @param sessionId
     * @return
     */
    @GetMapping("/getData")
    public R getData(@RequestParam(name = "sessionId") String sessionId) {
        try {
            return evalService.getData(sessionId);
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }

    /**
     * 根据开始日期和结束日期查询每天满意度调研的解决率和满意率
     * 解决率 已解决数量/总数量
     * 满意率 传入日期一天内(四星和五星数量/总数量)
     *
     * @param startDate
     * @param endDate
     * @return
     */
    @GetMapping("/getStatisticsData")
    public R getStatisticsData(String startDate, String endDate) {
        try {
            return evalService.getStatisticsData(startDate, endDate);
        } catch (Exception e) {
            return R.error(e.getMessage());
        }
    }
}
